

EFFECT.Mat = Material( "effects/select_ring" )

/*---------------------------------------------------------
   Initializes the effect. The data is a table of data 
   which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )
	data:GetEntity():EmitSound("ambient/explosions/explode_4.wav", 500, 100)
	self.NumParticles = data:GetEntity():GetNWInt("Volume")
	self.NumParticles = self.NumParticles / 10
	self.NumParticles = math.Round(self.NumParticles)
	self.PSize = data:GetEntity():GetNWInt("Volume")
	self.PSize = self.PSize / 50 * 2.4
	self.PSize = math.Round(self.PSize)
	local vOffset = data:GetOrigin()
	local Low = vOffset - Vector(32, 32, 32 )
	local High = vOffset + Vector(32, 32, 32 )
	local emitter = ParticleEmitter( vOffset )
	self.PSize = math.Clamp(self.PSize, 25, 400) / 1.5
	self.PSize = math.Round(self.PSize)
	self.NumParticles = math.Clamp(self.NumParticles, 20, 400) * 2
		if data:GetEntity():GetNWInt("DType") == 0 then
		for i=0, (self.NumParticles) do
			local Pos = VectorRand():GetNormalized()
			local Size = math.Clamp( self.PSize, 100, 400 ) / 2
			local particle = emitter:Add( "particles/flamelet"..math.random(1,5), vOffset + Pos)
			if (particle) then
				particle:SetVelocity( Pos * 2000)
				particle:SetLifeTime( 0 )
				particle:SetDieTime( self.PSize / math.Rand(40, 100))
				particle:SetStartAlpha( math.Rand( 200, 255 ) )
				particle:SetEndAlpha( 0 )
				particle:SetStartSize( self.PSize * math.Rand(1,3) )
				particle:SetEndSize( self.PSize * math.Rand(4,6) )
				particle:SetRoll( math.Rand(0, 360) )
				particle:SetColor( 255,100,100 )
			end
		end

		for i=0, (self.NumParticles) do
			local Pos = VectorRand():GetNormalized()
			local Size = math.Clamp( self.PSize, 100, 400 ) / 2
			local particle = emitter:Add( "particles/smokey", vOffset + Pos * math.Rand(20, 1000 ))
			if (particle) then
				particle:SetVelocity( Pos * math.random(10, 500))
				particle:SetLifeTime( 0 )
				particle:SetDieTime( self.PSize / math.Rand(5, 20))
				particle:SetStartAlpha( math.Rand( 200, 255 ) )
				particle:SetEndAlpha( 0 )
				particle:SetStartSize( self.PSize * 3 )
				particle:SetEndSize( self.PSize * 4 )
				particle:SetRoll( math.Rand(0, 360) )
				particle:SetRollDelta( math.Rand(-0.2, 0.2) )
				particle:SetColor( 64,64,64 )
				particle:SetAirResistance( 2 );
				particle:SetGravity( Vector( 0, 0, 0 ) );
				particle:SetCollide( true );
				particle:SetBounce( 1 )
			end
			
		end
		elseif data:GetEntity():GetNWInt("DType") == 1 then

		for i=0, (self.NumParticles / 2) do
		
			local Pos = VectorRand():GetNormalized()
			local Size = math.Clamp( self.PSize, 100, 400 ) / 2
			local particle = emitter:Add( "particles/flamelet"..math.random(1,5), vOffset + Pos * math.Rand(20, 1000 ))
			if (particle) then
				particle:SetVelocity( Pos * 2000)
				particle:SetLifeTime( 0 )
				particle:SetDieTime( self.PSize / math.Rand(120, 150))
				particle:SetStartAlpha( math.Rand( 200, 255 ) )
				particle:SetEndAlpha( 0 )
				particle:SetStartSize( self.PSize * 2 )
				particle:SetEndSize( self.PSize * 4 )
				particle:SetRoll( math.Rand(0, 360) )
				particle:SetRollDelta( math.Rand(-0.2, 0.2) )
				particle:SetColor( 0,0,255 )
				particle:SetAirResistance( 2 );
				particle:SetGravity( Vector( 0, 0, 0 ) );
				particle:SetCollide( true );
				particle:SetBounce( 1 )
			end
			
		end


		end
	emitter:Finish()
	
end


/*---------------------------------------------------------
   THINK
---------------------------------------------------------*/
function EFFECT:Think( )

	return false
end

/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()
end
